<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    // 获取上下文路径
    String contextPath = request.getContextPath();
%>
<div class="header">
    <div class="container">
        <a href="<%=contextPath%>/user_home" class="logo">在线商城</a>
        <div class="nav">
            <c:choose>
                <c:when test="${not empty sessionScope.user}">
                    <a href="<%=contextPath%>/cart">购物车</a>
                    <a href="<%=contextPath%>/orders">我的订单</a>
                    <a href="<%=contextPath%>/profile">${sessionScope.user.username}</a>
                    <a href="<%=contextPath%>/logout">退出</a>
                </c:when>
                <c:otherwise>
                    <a href="<%=contextPath%>/login">登录</a>
                    <a href="<%=contextPath%>/register">注册</a>
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</div>